:: Set encodeing to UTF-8 for console
@CHCP 65001
:: 安装thmar依赖库(esp32)
:: 依赖库: cmake, conan, python3

ECHO OFF 
SETLOCAL

SET machine=xtensa-esp32-elf
WHERE %machine%-gcc
IF ERRORLEVEL 1 (
	ECHO %machine%-gcc NOT FOUND.
	EXIT /B -1
)
ECHO %machine%-gcc found

where cmake
if errorlevel 1 (
	ECHO cmake NOT FOUND.
	exit /B -1
)
ECHO cmake found
where conan
if errorlevel 1 (
	ECHO conan NOT FOUND.
	exit /B -1
)
ECHO conan found
:: 检查conan 版本,要求conan 2
conan --version | findstr /C:"Conan version 2"
if errorlevel 1 (
	ECHO coan 2 required.
	exit /B -1
)
where python
if errorlevel 1 (
	ECHO python NOT FOUND.
	exit /B -1
)
ECHO python found
:: 检查Python 版本,要求Python 3
python --version | findstr /C:"Python 3"
if errorlevel 1 (
	ECHO python 3 required.
	exit /B -1
)
SET sh_folder=%~dp0
:: 删除最后的 '\'
SET sh_folder=%sh_folder:~0,-1%

conan install %sh_folder% -of %sh_folder%\build\%machine% -pr:h %sh_folder%\conan2\profiles\esp32_gcc -pr:b default ^
	-o build_test=False -o with_paho=False ^
	--build missing  

:: -pr:h esp32_gcc 指定目标平台的profile
:: -pr:b default  指定编译平台的profile
:: --build missing 编译缺少的依赖库

ENDLOCAL